****************Pegado de bases************************************
cd "C:\Users\xxxx\Documents\bases_latinobarometro" // Colocar dirección en donde se encuentran guardadas las bases de Latinobarometro
set more off
clear

append using Latinobarometro_2006_datos_esp_v2014_06_27.dta ///
Latinobarometro_2007_datos_esp_v2014_06_27.dta ///
Latinobarometro_2008_datos_esp_v2014_06_27.dta ///
Latinobarometro_2009_datos_esp_v2014_06_27.dta ///
Latinobarometro_2010_datos_esp_v2014_06_27.dta ///
Latinobarometro_2011_esp.dta ///
Latinobarometro2013.dta ///
Latinobarometro_2018_Esp_Stata_v20190303.dta ///
Latinobarometro_2020_Esp_Stata_v1_0.dta

replace numinves = 2011 if numinves == 16
replace numinves = 2013 if numinves == 17


*****armado variables*****

gen subp = .
replace subp = p13st_b if numinves == 2006
replace subp = p6stmb if numinves == 2007
replace subp = p12st_b if numinves == 2008
replace subp = p17st_b if numinves == 2009
replace subp = P13ST_B if numinves == 2010
replace subp = P11ST_B if numinves == 2011 | numinves == 2013
replace subp = p10stc_b if numinves == 2018
replace subp = p8st_b if numinves == 2020

recode subp (-6 -3 -2 -1 = .)
lab var subp "Escala subjetiva rico-pobre padres"

gen subh = .
replace subh = p13st_a if numinves == 2006
replace subh = p6stma if numinves == 2007
replace subh = p12st_a if numinves == 2008
replace subh = p17st_a if numinves == 2009
replace subh = P13ST_A if numinves == 2010
replace subh = P11ST_A if numinves == 2011 | numinves == 2013
replace subh = p10stc_a if numinves == 2018
replace subh = p8st_a if numinves == 2020

recode subh (-6 -2 -1 = .)
lab var subh "Escala subjetiva rico-pobre hijos"


gen sex = .
replace sex = s6 if numinves == 2006
replace sex = s10 if numinves == 2007
replace sex = s8 if numinves == 2008
replace sex = s5 if numinves == 2009
replace sex = S7 if numinves == 2010
replace sex = S16 if numinves == 2011
replace sex = S10 if numinves == 2013
replace sex = sexo if numinves >= 2018

recode sex (2 = 0)

lab var sex "Sexo"
lab def sex 1"Varon" 0"Mujer"
lab val sex sex

gen age = .
replace age = s7 if numinves == 2006
replace age = s11 if numinves == 2007
replace age = s9 if numinves == 2008
replace age = s6 if numinves == 2009
replace age = S8 if numinves == 2010
replace age = S17 if numinves == 2011
replace age = S11 if numinves == 2013
replace age = edad if numinves >= 2018

recode age (-2 = .)
lab var age "Edad"

gen age2 = age*age
lab var age2 "Edad al cuadrado"


gen cat_ocup = .
replace cat_ocup = s13a if numinves == 2006
replace cat_ocup = s17a if numinves == 2007
replace cat_ocup = s17a if numinves == 2008
replace cat_ocup = s14a if numinves == 2009
replace cat_ocup = S16A if numinves == 2010
replace cat_ocup = S23A if numinves == 2011
replace cat_ocup = S19_A if numinves == 2013
replace cat_ocup = s14a if numinves == 2018
replace cat_ocup = s24_a if numinves == 2020

recode cat_ocup (-2 -4 = .)
lab var cat_ocup "Categoria ocupacional"
lab def cat_ocup 1"Independiente" 2"Asalariado empresa publica" 3"Asalariado empresa privada" 4"Temporalmente no trabaja" 5"Retirado-pensionado" ///
6"No trabaja" 7"Estudiante"
lab val cat_ocup cat_ocup


gen ocup = .
replace ocup = s14 if numinves == 2006 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = s18 if numinves == 2007 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = s18 if numinves == 2008 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = s15 if numinves == 2009 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = S17 if numinves == 2010 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = S24 if numinves == 2011 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = S20 if numinves == 2013 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = s15 if numinves == 2018 & (cat_ocup >= 1 & cat_ocup <= 3)
replace ocup = s25 if numinves == 2020 & (cat_ocup >= 1 & cat_ocup <= 3)

replace ocup = s13b if numinves == 2006 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = s17b if numinves == 2007 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = s17b if numinves == 2008 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = s14b if numinves == 2009 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = S16B if numinves == 2010 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = S23B if numinves == 2011 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = S19_B if numinves == 2013 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = s14b if numinves == 2018 & (cat_ocup >= 4 & cat_ocup <= 5)
replace ocup = s24_b if numinves == 2020 & (cat_ocup >= 4 & cat_ocup <= 5)

replace ocup = 9 if cat_ocup == 6 | cat_ocup == 7

recode ocup (-4 -3 -2 = .)
lab var ocup "Ocupacion activos"
lab def ocup 1"Profesional indepediente" 2"Dueño de negocio" 3"Agricultor/pescador" 4"Trabajador por cuenta propia, ambulante" 5"Profesional asalariado" ///
6"Alto ejecutivo" 7"Ejecutivo de mando medio" 8"Otro empleado" 9"Inactivos sin ocup previa"
lab val ocup ocup


gen educ = .
replace educ = reeduc1 if numinves >= 2006 & numinves <= 2009
replace educ = REEDUC1 if numinves >= 2010 & numinves <= 2011
replace educ = REEDUC_1 if numinves == 2013 
replace educ = reeduc_1 if numinves == 2020 

recode educ (1/3 = 1) (4 5 = 2) (6 7 = 3) (-2 -4 0 = .), gen(educh)
replace educh = reeduc_1 if numinves == 2018

lab var educh "Nivel educativo alcanzado del hijo"
lab def educh 1"Básica y menos" 2"Secundaria, media, técnica y menos" 3 "Superior y más"
lab val educh educh
drop educ


gen sit_econ_gral = .
replace sit_econ_gral = p2st if numinves == 2006
replace sit_econ_gral = p100st if numinves == 2007
replace sit_econ_gral = p4st if numinves == 2008
replace sit_econ_gral = p3st_a if numinves == 2009
replace sit_econ_gral = P3ST_A if numinves == 2010
replace sit_econ_gral = P3ST_A if numinves == 2011
replace sit_econ_gral = P3STGBS if numinves == 2013
replace sit_econ_gral = p6stgbsc if numinves == 2018
replace sit_econ_gral = p4stgbs if numinves == 2020
lab var sit_econ_gral "Situación económica general del país"
lab val sit_econ_gral nivelsoc_enc
recode sit_econ_gral (-1 -2 = .)

gen ideologia = .
replace ideologia = p47st if numinves == 2006
replace ideologia = p67st if numinves == 2007
replace ideologia = p56st if numinves == 2008
replace ideologia = p69st if numinves == 2009
replace ideologia = P60ST if numinves == 2010
replace ideologia = P76ST if numinves == 2011
replace ideologia = P41ST if numinves == 2013
replace ideologia = p22st if numinves == 2018
replace ideologia = p18st if numinves == 2020

recode ideologia (-8 -6 -2 -1 97 = .)

lab var ideologia "Escala izquierda - derecha"


**********Bienes***********************
gen comp = .
replace comp = s15d if  numinves == 2006
replace comp = s19d if  numinves >= 2007 & numinves <= 2008
replace comp = s19f if  numinves == 2009
replace comp = S21F if  numinves == 2010
replace comp = S28D if  numinves == 2011
replace comp = S22_D if  numinves == 2013
replace comp = s21_c if  numinves == 2018
replace comp = s26_c if  numinves == 2020
recode comp (-4 -2 -1 = .) (2 = 0)
lab var comp "Computadora"

gen lavadora = .
replace lavadora = s15e if  numinves == 2006
replace lavadora = s19e if  numinves >= 2007 & numinves <= 2008
replace lavadora = s19g if  numinves == 2009
replace lavadora = S21E if  numinves == 2010
replace lavadora = S28E if  numinves == 2011
replace lavadora = S22_E if  numinves == 2013
replace lavadora = s21_e if  numinves == 2018
replace lavadora = s26_d if  numinves == 2020
recode lavadora (-4 -2 -1 = .) (2 = 0)
lab var lavadora "Lavadora"

gen telef = .
replace telef = s15f if  numinves == 2006
replace telef = s19f if  numinves >= 2007 & numinves <= 2008
replace telef = s19h if  numinves == 2009
replace telef = S21F if  numinves == 2010
replace telef = S28F if  numinves == 2011
replace telef = S22_F if  numinves == 2013
replace telef = s21_f if  numinves == 2018
replace telef = s26_e if  numinves == 2020
recode telef (-4 -2 -1 = .) (2 = 0)
lab var telef "Telefono"

gen celular = .
replace celular = s15g if  numinves == 2006
replace celular = s19g if  numinves >= 2007 & numinves <= 2008
replace celular = s19i if  numinves == 2009
replace celular = S21G if  numinves == 2010
replace celular = S28G if  numinves == 2011
replace celular = S22_G if  numinves == 2013
replace celular = s21_g if  numinves == 2018
replace celular = s26_f if  numinves == 2020
recode celular (-4 -2 -1 = .) (2 = 0)
lab var celular "Celular"

gen coche = .
replace coche = s15h if  numinves == 2006
replace coche = s19h if  numinves >= 2007 & numinves <= 2008
replace coche = s19j if  numinves == 2009
replace coche = S21H if  numinves == 2010
replace coche = S28H if  numinves == 2011
replace coche = S22_H if  numinves == 2013
replace coche = s21_i if  numinves == 2018
replace coche = s26_g if  numinves == 2020
recode coche (-4 -2 -1 = .) (2 = 0)
lab var coche "Coche"

gen agua_pot = .
replace agua_pot = s15j if  numinves == 2006
replace agua_pot = s19j if  numinves >= 2007 & numinves <= 2008
replace agua_pot = s19l if  numinves == 2009
replace agua_pot = S21L if  numinves == 2010
replace agua_pot = S28I if  numinves == 2011
replace agua_pot = S22_I if  numinves == 2013
replace agua_pot = s21_m if  numinves == 2018
replace agua_pot = s26_k if  numinves == 2020
recode agua_pot (-4 -2 -3 -1 = .) (2 = 0)
lab var agua_pot "Agua potable"

gen agua_cal = .
replace agua_cal = s15k if  numinves == 2006
replace agua_cal = s19k if  numinves >= 2007 & numinves <= 2008
replace agua_cal = s19m if  numinves == 2009
replace agua_cal = S21M if  numinves == 2010
replace agua_cal = S28J if  numinves == 2011
replace agua_cal = S22_J if  numinves == 2013
replace agua_cal = s21_j if  numinves == 2018
replace agua_cal = s26_h if  numinves == 2020
recode agua_cal (-4 -2 -3 -1 = .) (2 = 0)
lab var agua_cal "Agua caliente"

gen cloaca = .
replace cloaca = s15l if  numinves == 2006
replace cloaca = s19l if  numinves >= 2007 & numinves <= 2008
replace cloaca = s19n if  numinves == 2009
replace cloaca = S21N if  numinves == 2010
replace cloaca = S28K if  numinves == 2011
replace cloaca = S22_K if  numinves == 2013
replace cloaca = s21_k if  numinves == 2018
replace cloaca = s26_i if  numinves == 2020
recode cloaca (-4 -2 -3 -1 = .) (2 = 0)
lab var cloaca "Cloaca"

gen vivienda = .
replace vivienda = s15c if  numinves == 2006
replace vivienda = s19c if  numinves >= 2007 & numinves <= 2008
replace vivienda = s19e if  numinves == 2009
replace vivienda = S21E if  numinves == 2010
replace vivienda = S28C if  numinves == 2011
replace vivienda = S22_C if  numinves == 2013
replace vivienda = s21_b if  numinves == 2018
replace vivienda = s26_b if  numinves == 2020
recode vivienda (-4 -2 -3 -1 = .) (2 = 0)
lab var vivienda "Tenencia de vivienda"

************Cambio nombres variables***************
gen survey = numinves
gen country = idenpa


*************Arreglo variables año y país************
drop if country == 724 | country == 862 // elimina a España y Venezuela

gen anio = .
replace anio = 1 if survey == 2006
replace anio = 2 if survey == 2007
replace anio = 3 if survey == 2008
replace anio = 4 if survey == 2009
replace anio = 5 if survey == 2010
replace anio = 6 if survey == 2011
replace anio = 7 if survey == 2013
replace anio = 8 if survey == 2018
replace anio = 9 if survey == 2020

gen pais =.
replace pais = 1 if country == 32
replace pais = 2 if country == 68
replace pais = 3 if country == 76
replace pais = 4 if country == 152
replace pais = 5 if country == 170
replace pais = 6 if country == 188
replace pais = 7 if country == 214
replace pais = 8 if country == 218
replace pais = 9 if country == 222
replace pais = 10 if country == 320
replace pais = 11 if country == 340
replace pais = 12 if country == 484
replace pais = 13 if country == 558
replace pais = 14 if country == 591
replace pais = 15 if country == 600
replace pais = 16 if country == 604
replace pais = 17 if country == 858
replace pais = 18 if country == 862

*Interacción país año*********
egen countryyear=group(pais anio)



****************Variables agregadas*********************************

*GDP
gen gdp = .
lab var gdp "GDP per cápita BM"

replace gdp= 	5919	if country ==	32	& survey ==	2006
replace gdp= 	7245	if country ==	32	& survey ==	2007
replace gdp= 	9021	if country ==	32	& survey ==	2008
replace gdp= 	8225	if country ==	32	& survey ==	2009
replace gdp= 	10386	if country ==	32	& survey ==	2010
replace gdp= 	12849	if country ==	32	& survey ==	2011
replace gdp= 	13080	if country ==	32	& survey ==	2013
replace gdp= 	11795	if country ==	32	& survey ==	2018
replace gdp= 	8579	if country ==	32	& survey ==	2020
					
replace gdp= 	1219	if country ==	68	& survey ==	2006
replace gdp= 	1373	if country ==	68	& survey ==	2007
replace gdp= 	1715	if country ==	68	& survey ==	2008
replace gdp= 	1754	if country ==	68	& survey ==	2009
replace gdp= 	1955	if country ==	68	& survey ==	2010
replace gdp= 	2346	if country ==	68	& survey ==	2011
replace gdp= 	2908	if country ==	68	& survey ==	2013
replace gdp= 	3549	if country ==	68	& survey ==	2018
replace gdp= 	3133	if country ==	68	& survey ==	2020
					
replace gdp= 	5886	if country ==	76	& survey ==	2006
replace gdp= 	7348	if country ==	76	& survey ==	2007
replace gdp= 	8831	if country ==	76	& survey ==	2008
replace gdp= 	8598	if country ==	76	& survey ==	2009
replace gdp= 	11286	if country ==	76	& survey ==	2010
replace gdp= 	13245	if country ==	76	& survey ==	2011
replace gdp= 	12300	if country ==	76	& survey ==	2013
replace gdp= 	9151	if country ==	76	& survey ==	2018
replace gdp= 	6797	if country ==	76	& survey ==	2020
					
replace gdp= 	9465	if country ==	152	& survey ==	2006
replace gdp= 	10502	if country ==	152	& survey ==	2007
replace gdp= 	10751	if country ==	152	& survey ==	2008
replace gdp= 	10209	if country ==	152	& survey ==	2009
replace gdp= 	12808	if country ==	152	& survey ==	2010
replace gdp= 	14637	if country ==	152	& survey ==	2011
replace gdp= 	15843	if country ==	152	& survey ==	2013
replace gdp= 	15888	if country ==	152	& survey ==	2018
replace gdp= 	13232	if country ==	152	& survey ==	2020
					
replace gdp= 	3741	if country ==	170	& survey ==	2006
replace gdp= 	4714	if country ==	170	& survey ==	2007
replace gdp= 	5473	if country ==	170	& survey ==	2008
replace gdp= 	5193	if country ==	170	& survey ==	2009
replace gdp= 	6337	if country ==	170	& survey ==	2010
replace gdp= 	7335	if country ==	170	& survey ==	2011
replace gdp= 	8218	if country ==	170	& survey ==	2013
replace gdp= 	6730	if country ==	170	& survey ==	2018
replace gdp= 	5335	if country ==	170	& survey ==	2020
					
replace gdp= 	5227	if country ==	188	& survey ==	2006
replace gdp= 	6104	if country ==	188	& survey ==	2007
replace gdp= 	6901	if country ==	188	& survey ==	2008
replace gdp= 	6801	if country ==	188	& survey ==	2009
replace gdp= 	8227	if country ==	188	& survey ==	2010
replace gdp= 	9230	if country ==	188	& survey ==	2011
replace gdp= 	10744	if country ==	188	& survey ==	2013
replace gdp= 	12485	if country ==	188	& survey ==	2018
replace gdp= 	12141	if country ==	188	& survey ==	2020
					
replace gdp= 	4109	if country ==	214	& survey ==	2006
replace gdp= 	4708	if country ==	214	& survey ==	2007
replace gdp= 	5088	if country ==	214	& survey ==	2008
replace gdp= 	5039	if country ==	214	& survey ==	2009
replace gdp= 	5555	if country ==	214	& survey ==	2010
replace gdp= 	5913	if country ==	214	& survey ==	2011
replace gdp= 	6238	if country ==	214	& survey ==	2012
replace gdp= 	8051	if country ==	214	& survey ==	2018
replace gdp= 	7268	if country ==	214	& survey ==	2020
					
replace gdp= 	3329	if country ==	218	& survey ==	2006
replace gdp= 	3568	if country ==	218	& survey ==	2007
replace gdp= 	4249	if country ==	218	& survey ==	2008
replace gdp= 	4232	if country ==	218	& survey ==	2009
replace gdp= 	4634	if country ==	218	& survey ==	2010
replace gdp= 	5201	if country ==	218	& survey ==	2011
replace gdp= 	6056	if country ==	218	& survey ==	2013
replace gdp= 	6296	if country ==	218	& survey ==	2018
replace gdp= 	5600	if country ==	218	& survey ==	2020
					
replace gdp= 	2632	if country ==	222	& survey ==	2006
replace gdp= 	2786	if country ==	222	& survey ==	2007
replace gdp= 	2933	if country ==	222	& survey ==	2008
replace gdp= 	2858	if country ==	222	& survey ==	2009
replace gdp= 	2983	if country ==	222	& survey ==	2010
replace gdp= 	3266	if country ==	222	& survey ==	2011
replace gdp= 	3510	if country ==	222	& survey ==	2013
replace gdp= 	4053	if country ==	222	& survey ==	2018
replace gdp= 	3799	if country ==	222	& survey ==	2020
					
replace gdp= 	2251	if country ==	320	& survey ==	2006
replace gdp= 	2491	if country ==	320	& survey ==	2007
replace gdp= 	2802	if country ==	320	& survey ==	2008
replace gdp= 	2652	if country ==	320	& survey ==	2009
replace gdp= 	2853	if country ==	320	& survey ==	2010
replace gdp= 	3228	if country ==	320	& survey ==	2011
replace gdp= 	3523	if country ==	320	& survey ==	2013
replace gdp= 	4478	if country ==	320	& survey ==	2018
replace gdp= 	4603	if country ==	320	& survey ==	2020
					
replace gdp= 	1420	if country ==	340	& survey ==	2006
replace gdp= 	1572	if country ==	340	& survey ==	2007
replace gdp= 	1728	if country ==	340	& survey ==	2008
replace gdp= 	1777	if country ==	340	& survey ==	2009
replace gdp= 	1891	if country ==	340	& survey ==	2010
replace gdp= 	2074	if country ==	340	& survey ==	2011
replace gdp= 	2088	if country ==	340	& survey ==	2013
replace gdp= 	2493	if country ==	340	& survey ==	2018
replace gdp= 	2389	if country ==	340	& survey ==	2020
					
replace gdp= 	9068	if country ==	484	& survey ==	2006
replace gdp= 	9643	if country ==	484	& survey ==	2007
replace gdp= 	10017	if country ==	484	& survey ==	2008
replace gdp= 	8003	if country ==	484	& survey ==	2009
replace gdp= 	9271	if country ==	484	& survey ==	2010
replace gdp= 	10203	if country ==	484	& survey ==	2011
replace gdp= 	10725	if country ==	484	& survey ==	2013
replace gdp= 	9687	if country ==	484	& survey ==	2018
replace gdp= 	8329	if country ==	484	& survey ==	2020
					
replace gdp= 	1227	if country ==	558	& survey ==	2006
replace gdp= 	1328	if country ==	558	& survey ==	2007
replace gdp= 	1499	if country ==	558	& survey ==	2008
replace gdp= 	1444	if country ==	558	& survey ==	2009
replace gdp= 	1504	if country ==	558	& survey ==	2010
replace gdp= 	1656	if country ==	558	& survey ==	2011
replace gdp= 	1812	if country ==	558	& survey ==	2013
replace gdp= 	2015	if country ==	558	& survey ==	2018
replace gdp= 	1905	if country ==	558	& survey ==	2020
					
replace gdp= 	5349	if country ==	591	& survey ==	2006
replace gdp= 	6166	if country ==	591	& survey ==	2007
replace gdp= 	7154	if country ==	591	& survey ==	2008
replace gdp= 	7576	if country ==	591	& survey ==	2009
replace gdp= 	8082	if country ==	591	& survey ==	2010
replace gdp= 	9358	if country ==	591	& survey ==	2011
replace gdp= 	11889	if country ==	591	& survey ==	2013
replace gdp= 	15545	if country ==	591	& survey ==	2018
replace gdp= 	12510	if country ==	591	& survey ==	2020
					
replace gdp= 	2271	if country ==	600	& survey ==	2006
replace gdp= 	2977	if country ==	600	& survey ==	2007
replace gdp= 	4048	if country ==	600	& survey ==	2008
replace gdp= 	3627	if country ==	600	& survey ==	2009
replace gdp= 	4359	if country ==	600	& survey ==	2010
replace gdp= 	5329	if country ==	600	& survey ==	2011
replace gdp= 	5937	if country ==	600	& survey ==	2013
replace gdp= 	5783	if country ==	600	& survey ==	2018
replace gdp= 	5001	if country ==	600	& survey ==	2020
					
replace gdp= 	3154	if country ==	604	& survey ==	2006
replace gdp= 	3606	if country ==	604	& survey ==	2007
replace gdp= 	4221	if country ==	604	& survey ==	2008
replace gdp= 	4196	if country ==	604	& survey ==	2009
replace gdp= 	5082	if country ==	604	& survey ==	2010
replace gdp= 	5869	if country ==	604	& survey ==	2011
replace gdp= 	6757	if country ==	604	& survey ==	2013
replace gdp= 	6958	if country ==	604	& survey ==	2018
replace gdp= 	6127	if country ==	604	& survey ==	2020
					
replace gdp= 	5888	if country ==	858	& survey ==	2006
replace gdp= 	7027	if country ==	858	& survey ==	2007
replace gdp= 	9091	if country ==	858	& survey ==	2008
replace gdp= 	9452	if country ==	858	& survey ==	2009
replace gdp= 	11992	if country ==	858	& survey ==	2010
replace gdp= 	14237	if country ==	858	& survey ==	2011
replace gdp= 	16974	if country ==	858	& survey ==	2013
replace gdp= 	18704	if country ==	858	& survey ==	2018
replace gdp= 	15438	if country ==	858	& survey ==	2020
					
replace gdp= 	6833	if country ==	862	& survey ==	2006
replace gdp= 	8454	if country ==	862	& survey ==	2007
replace gdp= 	11433	if country ==	862	& survey ==	2008
replace gdp= 	11765	if country ==	862	& survey ==	2009
replace gdp= 	13825	if country ==	862	& survey ==	2010
replace gdp= 	10956	if country ==	862	& survey ==	2011
replace gdp= 	12458	if country ==	862	& survey ==	2013
replace gdp= 	12458	if country ==	862	& survey ==	2018
replace gdp= 	12458	if country ==	862	& survey ==	2020

gen log_gdp = log(gdp)
lab var log_gdp "PIB per capita (log)"


gen gdp_wid =.
lab var gdp_wid "GDP per cápita WID" 

replace gdp_wid= 	27198.3194	if country ==	32	& survey ==	2006
replace gdp_wid= 	28628.2471	if country ==	32	& survey ==	2007
replace gdp_wid= 	30215.1217	if country ==	32	& survey ==	2008
replace gdp_wid= 	28402.33	if country ==	32	& survey ==	2009
replace gdp_wid= 	31751.7628	if country ==	32	& survey ==	2010
replace gdp_wid= 	34227.5361	if country ==	32	& survey ==	2011
replace gdp_wid= 	35081.076	if country ==	32	& survey ==	2013
replace gdp_wid= 	32198.4872	if country ==	32	& survey ==	2018
replace gdp_wid= 	27730.6449	if country ==	32	& survey ==	2020
					
replace gdp_wid= 	11825.4208	if country ==	68	& survey ==	2006
replace gdp_wid= 	12073.2474	if country ==	68	& survey ==	2007
replace gdp_wid= 	12511.6983	if country ==	68	& survey ==	2008
replace gdp_wid= 	12626.1404	if country ==	68	& survey ==	2009
replace gdp_wid= 	12838.2953	if country ==	68	& survey ==	2010
replace gdp_wid= 	13183.4221	if country ==	68	& survey ==	2011
replace gdp_wid= 	14115.3506	if country ==	68	& survey ==	2013
replace gdp_wid= 	15742.2588	if country ==	68	& survey ==	2018
replace gdp_wid= 	14029.866	if country ==	68	& survey ==	2020
					
replace gdp_wid= 	23534.9706	if country ==	76	& survey ==	2006
replace gdp_wid= 	24455.9816	if country ==	76	& survey ==	2007
replace gdp_wid= 	25203.659	if country ==	76	& survey ==	2008
replace gdp_wid= 	24699.0697	if country ==	76	& survey ==	2009
replace gdp_wid= 	26071.3572	if country ==	76	& survey ==	2010
replace gdp_wid= 	26625.6752	if country ==	76	& survey ==	2011
replace gdp_wid= 	27024.4903	if country ==	76	& survey ==	2013
replace gdp_wid= 	24152.8159	if country ==	76	& survey ==	2018
replace gdp_wid= 	22840.158	if country ==	76	& survey ==	2020
					
replace gdp_wid= 	30356.3505	if country ==	152	& survey ==	2006
replace gdp_wid= 	31257.8343	if country ==	152	& survey ==	2007
replace gdp_wid= 	31756.2728	if country ==	152	& survey ==	2008
replace gdp_wid= 	30675.1981	if country ==	152	& survey ==	2009
replace gdp_wid= 	31865.6992	if country ==	152	& survey ==	2010
replace gdp_wid= 	33227.369	if country ==	152	& survey ==	2011
replace gdp_wid= 	35150.6697	if country ==	152	& survey ==	2013
replace gdp_wid= 	35434.2683	if country ==	152	& survey ==	2018
replace gdp_wid= 	32646.4158	if country ==	152	& survey ==	2020
					
replace gdp_wid= 	18632.8989	if country ==	170	& survey ==	2006
replace gdp_wid= 	19393.2688	if country ==	170	& survey ==	2007
replace gdp_wid= 	19720.5203	if country ==	170	& survey ==	2008
replace gdp_wid= 	19496.6406	if country ==	170	& survey ==	2009
replace gdp_wid= 	20253.0443	if country ==	170	& survey ==	2010
replace gdp_wid= 	21214.4232	if country ==	170	& survey ==	2011
replace gdp_wid= 	22286.5921	if country ==	170	& survey ==	2013
replace gdp_wid= 	22752.4258	if country ==	170	& survey ==	2018
replace gdp_wid= 	20998.7791	if country ==	170	& survey ==	2020
					
replace gdp_wid= 	24646.2524	if country ==	188	& survey ==	2006
replace gdp_wid= 	25993.3935	if country ==	188	& survey ==	2007
replace gdp_wid= 	26550.1343	if country ==	188	& survey ==	2008
replace gdp_wid= 	25680.3476	if country ==	188	& survey ==	2009
replace gdp_wid= 	26417.4927	if country ==	188	& survey ==	2010
replace gdp_wid= 	26982.8815	if country ==	188	& survey ==	2011
replace gdp_wid= 	27803.6909	if country ==	188	& survey ==	2013
replace gdp_wid= 	30315.2552	if country ==	188	& survey ==	2018
replace gdp_wid= 	28829.0717	if country ==	188	& survey ==	2020
					
replace gdp_wid= 	20772.8904	if country ==	214	& survey ==	2006
replace gdp_wid= 	21855.1696	if country ==	214	& survey ==	2007
replace gdp_wid= 	22097.6485	if country ==	214	& survey ==	2008
replace gdp_wid= 	21854.6656	if country ==	214	& survey ==	2009
replace gdp_wid= 	23197.7345	if country ==	214	& survey ==	2010
replace gdp_wid= 	23429.0651	if country ==	214	& survey ==	2011
replace gdp_wid= 	24227.4068	if country ==	214	& survey ==	2012
replace gdp_wid= 	30209.2619	if country ==	214	& survey ==	2018
replace gdp_wid= 	28658.7176	if country ==	214	& survey ==	2020
					
replace gdp_wid= 	18283.7168	if country ==	218	& survey ==	2006
replace gdp_wid= 	18223.0332	if country ==	218	& survey ==	2007
replace gdp_wid= 	18909.2847	if country ==	218	& survey ==	2008
replace gdp_wid= 	18559.0369	if country ==	218	& survey ==	2009
replace gdp_wid= 	18758.844	if country ==	218	& survey ==	2010
replace gdp_wid= 	19774.6603	if country ==	218	& survey ==	2011
replace gdp_wid= 	20965.1126	if country ==	218	& survey ==	2013
replace gdp_wid= 	19767.6358	if country ==	218	& survey ==	2018
replace gdp_wid= 	17399.8044	if country ==	218	& survey ==	2020
					
replace gdp_wid= 	13830.521	if country ==	222	& survey ==	2006
replace gdp_wid= 	13917.5262	if country ==	222	& survey ==	2007
replace gdp_wid= 	14050.3467	if country ==	222	& survey ==	2008
replace gdp_wid= 	13591.0915	if country ==	222	& survey ==	2009
replace gdp_wid= 	13694.3964	if country ==	222	& survey ==	2010
replace gdp_wid= 	14008.4961	if country ==	222	& survey ==	2011
replace gdp_wid= 	14241.0974	if country ==	222	& survey ==	2013
replace gdp_wid= 	14649.2508	if country ==	222	& survey ==	2018
replace gdp_wid= 	13324.7895	if country ==	222	& survey ==	2020
					
replace gdp_wid= 	15663.7074	if country ==	320	& survey ==	2006
replace gdp_wid= 	16121.2208	if country ==	320	& survey ==	2007
replace gdp_wid= 	16110.6319	if country ==	320	& survey ==	2008
replace gdp_wid= 	15660.3091	if country ==	320	& survey ==	2009
replace gdp_wid= 	15588.354	if country ==	320	& survey ==	2010
replace gdp_wid= 	15680.9944	if country ==	320	& survey ==	2011
replace gdp_wid= 	15650.0896	if country ==	320	& survey ==	2013
replace gdp_wid= 	15813.0844	if country ==	320	& survey ==	2018
replace gdp_wid= 	15203.042	if country ==	320	& survey ==	2020
					
replace gdp_wid= 	10377.0598	if country ==	340	& survey ==	2006
replace gdp_wid= 	10649.6222	if country ==	340	& survey ==	2007
replace gdp_wid= 	10736.2176	if country ==	340	& survey ==	2008
replace gdp_wid= 	10134.0486	if country ==	340	& survey ==	2009
replace gdp_wid= 	10170.3097	if country ==	340	& survey ==	2010
replace gdp_wid= 	10226.7994	if country ==	340	& survey ==	2011
replace gdp_wid= 	10270.5311	if country ==	340	& survey ==	2013
replace gdp_wid= 	10634.6006	if country ==	340	& survey ==	2018
replace gdp_wid= 	9369.8094	if country ==	340	& survey ==	2020
					
replace gdp_wid= 	32434.0058	if country ==	484	& survey ==	2006
replace gdp_wid= 	32782.2203	if country ==	484	& survey ==	2007
replace gdp_wid= 	32489.7661	if country ==	484	& survey ==	2008
replace gdp_wid= 	30285.3182	if country ==	484	& survey ==	2009
replace gdp_wid= 	31200.1463	if country ==	484	& survey ==	2010
replace gdp_wid= 	31827.4579	if country ==	484	& survey ==	2011
replace gdp_wid= 	32405.9621	if country ==	484	& survey ==	2013
replace gdp_wid= 	33483.6505	if country ==	484	& survey ==	2018
replace gdp_wid= 	29597.8044	if country ==	484	& survey ==	2020
					
replace gdp_wid= 	8985.2238	if country ==	558	& survey ==	2006
replace gdp_wid= 	9183.936	if country ==	558	& survey ==	2007
replace gdp_wid= 	9247.5376	if country ==	558	& survey ==	2008
replace gdp_wid= 	8712.692	if country ==	558	& survey ==	2009
replace gdp_wid= 	8869.1227	if country ==	558	& survey ==	2010
replace gdp_wid= 	9191.3763	if country ==	558	& survey ==	2011
replace gdp_wid= 	9776.3274	if country ==	558	& survey ==	2013
replace gdp_wid= 	10172.9761	if country ==	558	& survey ==	2018
replace gdp_wid= 	9236.9943	if country ==	558	& survey ==	2020
					
replace gdp_wid= 	30784.39	if country ==	591	& survey ==	2006
replace gdp_wid= 	33657.3268	if country ==	591	& survey ==	2007
replace gdp_wid= 	36116.5154	if country ==	591	& survey ==	2008
replace gdp_wid= 	35726.9388	if country ==	591	& survey ==	2009
replace gdp_wid= 	36950.5447	if country ==	591	& survey ==	2010
replace gdp_wid= 	40241.8027	if country ==	591	& survey ==	2011
replace gdp_wid= 	45227.4684	if country ==	591	& survey ==	2013
replace gdp_wid= 	51683.9001	if country ==	591	& survey ==	2018
replace gdp_wid= 	41808.6018	if country ==	591	& survey ==	2020
					
replace gdp_wid= 	17586.0927	if country ==	600	& survey ==	2006
replace gdp_wid= 	18083.5293	if country ==	600	& survey ==	2007
replace gdp_wid= 	18808.3522	if country ==	600	& survey ==	2008
replace gdp_wid= 	18322.9157	if country ==	600	& survey ==	2009
replace gdp_wid= 	19873.6929	if country ==	600	& survey ==	2010
replace gdp_wid= 	20243.2962	if country ==	600	& survey ==	2011
replace gdp_wid= 	20733.1201	if country ==	600	& survey ==	2013
replace gdp_wid= 	22616.5877	if country ==	600	& survey ==	2018
replace gdp_wid= 	21511.1376	if country ==	600	& survey ==	2020
					
replace gdp_wid= 	14809.7595	if country ==	604	& survey ==	2006
replace gdp_wid= 	15814.7111	if country ==	604	& survey ==	2007
replace gdp_wid= 	16993.5049	if country ==	604	& survey ==	2008
replace gdp_wid= 	16916.9264	if country ==	604	& survey ==	2009
replace gdp_wid= 	18039.0232	if country ==	604	& survey ==	2010
replace gdp_wid= 	18842.6415	if country ==	604	& survey ==	2011
replace gdp_wid= 	20356.0441	if country ==	604	& survey ==	2013
replace gdp_wid= 	20753.1374	if country ==	604	& survey ==	2018
replace gdp_wid= 	17809.7166	if country ==	604	& survey ==	2020
					
replace gdp_wid= 	23824.6488	if country ==	858	& survey ==	2006
replace gdp_wid= 	25244.3291	if country ==	858	& survey ==	2007
replace gdp_wid= 	26878.1692	if country ==	858	& survey ==	2008
replace gdp_wid= 	27823.5879	if country ==	858	& survey ==	2009
replace gdp_wid= 	29286.6083	if country ==	858	& survey ==	2010
replace gdp_wid= 	30827.4642	if country ==	858	& survey ==	2011
replace gdp_wid= 	33052.7845	if country ==	858	& survey ==	2013
replace gdp_wid= 	34300.0384	if country ==	858	& survey ==	2018
replace gdp_wid= 	31970.6849	if country ==	858	& survey ==	2020
					
replace gdp_wid= 	32795.1798	if country ==	862	& survey ==	2006
replace gdp_wid= 	34850.5985	if country ==	862	& survey ==	2007
replace gdp_wid= 	35871.6081	if country ==	862	& survey ==	2008
replace gdp_wid= 	33960.2119	if country ==	862	& survey ==	2009
replace gdp_wid= 	32728.9266	if country ==	862	& survey ==	2010
replace gdp_wid= 	33325.0375	if country ==	862	& survey ==	2011
replace gdp_wid= 	34176.2589	if country ==	862	& survey ==	2013
replace gdp_wid= 	17320.1188	if country ==	862	& survey ==	2018
replace gdp_wid= 	8871.7672	if country ==	862	& survey ==	2020

gen log_gdp_wid = log(gdp_wid)
lab var log_gdp_wid "GDP per cápita WID (log)" 

gen gini=.  
lab var gini "GINI BM"

replace gini= 	46.3	if country ==	32	& survey ==	2006
replace gini= 	46.2	if country ==	32	& survey ==	2007
replace gini= 	44.9	if country ==	32	& survey ==	2008
replace gini= 	43.7	if country ==	32	& survey ==	2009
replace gini= 	43.6	if country ==	32	& survey ==	2010
replace gini= 	42.6	if country ==	32	& survey ==	2011
replace gini= 	40.9	if country ==	32	& survey ==	2013
replace gini= 	41.3	if country ==	32	& survey ==	2018
replace gini= 	42.3	if country ==	32	& survey ==	2020
					
replace gini= 	56.7	if country ==	68	& survey ==	2006
replace gini= 	54.5	if country ==	68	& survey ==	2007
replace gini= 	50.8	if country ==	68	& survey ==	2008
replace gini= 	49.2	if country ==	68	& survey ==	2009
replace gini= 	49.2	if country ==	68	& survey ==	2010
replace gini= 	46.1	if country ==	68	& survey ==	2011
replace gini= 	47.6	if country ==	68	& survey ==	2013
replace gini= 	42.6	if country ==	68	& survey ==	2018
replace gini= 	43.6	if country ==	68	& survey ==	2020
					
replace gini= 	55.6	if country ==	76	& survey ==	2006
replace gini= 	54.9	if country ==	76	& survey ==	2007
replace gini= 	54	if country ==	76	& survey ==	2008
replace gini= 	53.7	if country ==	76	& survey ==	2009
replace gini= 	53.7	if country ==	76	& survey ==	2010
replace gini= 	52.9	if country ==	76	& survey ==	2011
replace gini= 	52.7	if country ==	76	& survey ==	2013
replace gini= 	53.9	if country ==	76	& survey ==	2018
replace gini= 	48.9	if country ==	76	& survey ==	2020
					
replace gini= 	47.3	if country ==	152	& survey ==	2006
replace gini= 	47.3	if country ==	152	& survey ==	2007
replace gini= 	47.3	if country ==	152	& survey ==	2008
replace gini= 	47	if country ==	152	& survey ==	2009
replace gini= 	47	if country ==	152	& survey ==	2010
replace gini= 	46	if country ==	152	& survey ==	2011
replace gini= 	45.8	if country ==	152	& survey ==	2013
replace gini= 	44.4	if country ==	152	& survey ==	2018
replace gini= 	44.9	if country ==	152	& survey ==	2020
					
replace gini= 	53.9	if country ==	170	& survey ==	2006
replace gini= 	53.9	if country ==	170	& survey ==	2007
replace gini= 	55.3	if country ==	170	& survey ==	2008
replace gini= 	54.3	if country ==	170	& survey ==	2009
replace gini= 	54.6	if country ==	170	& survey ==	2010
replace gini= 	53.5	if country ==	170	& survey ==	2011
replace gini= 	52.6	if country ==	170	& survey ==	2013
replace gini= 	50.4	if country ==	170	& survey ==	2018
replace gini= 	54.2	if country ==	170	& survey ==	2020
					
replace gini= 	49.3	if country ==	188	& survey ==	2006
replace gini= 	49.3	if country ==	188	& survey ==	2007
replace gini= 	48.6	if country ==	188	& survey ==	2008
replace gini= 	50.6	if country ==	188	& survey ==	2009
replace gini= 	48	if country ==	188	& survey ==	2010
replace gini= 	48.8	if country ==	188	& survey ==	2011
replace gini= 	49.2	if country ==	188	& survey ==	2013
replace gini= 	48	if country ==	188	& survey ==	2018
replace gini= 	49.3	if country ==	188	& survey ==	2020
					
replace gini= 	52	if country ==	214	& survey ==	2006
replace gini= 	48.9	if country ==	214	& survey ==	2007
replace gini= 	48.1	if country ==	214	& survey ==	2008
replace gini= 	48.9	if country ==	214	& survey ==	2009
replace gini= 	47.3	if country ==	214	& survey ==	2010
replace gini= 	47.7	if country ==	214	& survey ==	2011
replace gini= 	47.7	if country ==	214	& survey ==	2012
replace gini= 	43.7	if country ==	214	& survey ==	2018
replace gini= 	39.6	if country ==	214	& survey ==	2020
					
replace gini= 	52.3	if country ==	218	& survey ==	2006
replace gini= 	53.4	if country ==	218	& survey ==	2007
replace gini= 	49.8	if country ==	218	& survey ==	2008
replace gini= 	48.5	if country ==	218	& survey ==	2009
replace gini= 	48.8	if country ==	218	& survey ==	2010
replace gini= 	45.9	if country ==	218	& survey ==	2011
replace gini= 	46.9	if country ==	218	& survey ==	2013
replace gini= 	45.4	if country ==	218	& survey ==	2018
replace gini= 	47.3	if country ==	218	& survey ==	2020
					
replace gini= 	45.7	if country ==	222	& survey ==	2006
replace gini= 	45.2	if country ==	222	& survey ==	2007
replace gini= 	46.9	if country ==	222	& survey ==	2008
replace gini= 	45.8	if country ==	222	& survey ==	2009
replace gini= 	43.5	if country ==	222	& survey ==	2010
replace gini= 	42.3	if country ==	222	& survey ==	2011
replace gini= 	43.4	if country ==	222	& survey ==	2013
replace gini= 	38.6	if country ==	222	& survey ==	2018
replace gini= 	38.8	if country ==	222	& survey ==	2020
					
replace gini= 	54.6	if country ==	320	& survey ==	2006
replace gini= 	54.6	if country ==	320	& survey ==	2007
replace gini= 	54.6	if country ==	320	& survey ==	2008
replace gini= 	54.6	if country ==	320	& survey ==	2009
replace gini= 	54.6	if country ==	320	& survey ==	2010
replace gini= 	54.6	if country ==	320	& survey ==	2011
replace gini= 	54.6	if country ==	320	& survey ==	2013
replace gini= 	48.3	if country ==	320	& survey ==	2018
replace gini= 	48.3	if country ==	320	& survey ==	2020
					
replace gini= 	57.5	if country ==	340	& survey ==	2006
replace gini= 	55.8	if country ==	340	& survey ==	2007
replace gini= 	55.5	if country ==	340	& survey ==	2008
replace gini= 	51.3	if country ==	340	& survey ==	2009
replace gini= 	53.1	if country ==	340	& survey ==	2010
replace gini= 	52.6	if country ==	340	& survey ==	2011
replace gini= 	50	if country ==	340	& survey ==	2013
replace gini= 	48.9	if country ==	340	& survey ==	2018
replace gini= 	48.2	if country ==	340	& survey ==	2020
					
replace gini= 	48.9	if country ==	484	& survey ==	2006
replace gini= 	48.9	if country ==	484	& survey ==	2007
replace gini= 	49.9	if country ==	484	& survey ==	2008
replace gini= 	49.9	if country ==	484	& survey ==	2009
replace gini= 	47.2	if country ==	484	& survey ==	2010
replace gini= 	47.2	if country ==	484	& survey ==	2011
replace gini= 	47.2	if country ==	484	& survey ==	2013
replace gini= 	46.7	if country ==	484	& survey ==	2018
replace gini= 	45.4	if country ==	484	& survey ==	2020
					
replace gini= 	48.8	if country ==	558	& survey ==	2006
replace gini= 	48.8	if country ==	558	& survey ==	2007
replace gini= 	48.8	if country ==	558	& survey ==	2008
replace gini= 	43.9	if country ==	558	& survey ==	2009
replace gini= 	43.9	if country ==	558	& survey ==	2010
replace gini= 	43.9	if country ==	558	& survey ==	2011
replace gini= 	43.9	if country ==	558	& survey ==	2013
replace gini= 	46.2	if country ==	558	& survey ==	2018
replace gini= 	46.2	if country ==	558	& survey ==	2020
					
replace gini= 	54.6	if country ==	591	& survey ==	2006
replace gini= 	52.7	if country ==	591	& survey ==	2007
replace gini= 	52.7	if country ==	591	& survey ==	2008
replace gini= 	51.8	if country ==	591	& survey ==	2009
replace gini= 	51.6	if country ==	591	& survey ==	2010
replace gini= 	51.3	if country ==	591	& survey ==	2011
replace gini= 	51.5	if country ==	591	& survey ==	2013
replace gini= 	49.2	if country ==	591	& survey ==	2018
replace gini= 	49.8	if country ==	591	& survey ==	2020
					
replace gini= 	53	if country ==	600	& survey ==	2006
replace gini= 	53	if country ==	600	& survey ==	2007
replace gini= 	50.7	if country ==	600	& survey ==	2008
replace gini= 	49.1	if country ==	600	& survey ==	2009
replace gini= 	51	if country ==	600	& survey ==	2010
replace gini= 	52.3	if country ==	600	& survey ==	2011
replace gini= 	47.9	if country ==	600	& survey ==	2013
replace gini= 	46	if country ==	600	& survey ==	2018
replace gini= 	43.5	if country ==	600	& survey ==	2020
					
replace gini= 	50.3	if country ==	604	& survey ==	2006
replace gini= 	50	if country ==	604	& survey ==	2007
replace gini= 	47.5	if country ==	604	& survey ==	2008
replace gini= 	47	if country ==	604	& survey ==	2009
replace gini= 	45.5	if country ==	604	& survey ==	2010
replace gini= 	44.7	if country ==	604	& survey ==	2011
replace gini= 	43.9	if country ==	604	& survey ==	2013
replace gini= 	42.4	if country ==	604	& survey ==	2018
replace gini= 	43.8	if country ==	604	& survey ==	2020
					
replace gini= 	45.9	if country ==	858	& survey ==	2006
replace gini= 	46.4	if country ==	858	& survey ==	2007
replace gini= 	45.1	if country ==	858	& survey ==	2008
replace gini= 	45.5	if country ==	858	& survey ==	2009
replace gini= 	44.5	if country ==	858	& survey ==	2010
replace gini= 	42.2	if country ==	858	& survey ==	2011
replace gini= 	40.5	if country ==	858	& survey ==	2013
replace gini= 	39.7	if country ==	858	& survey ==	2018
replace gini= 	40.2	if country ==	858	& survey ==	2020
					
					
gen gini_wid = .
lab var gini_wid "GINI WID"

replace gini_wid= 	0.533074717	if country ==	32	& survey ==	2006
replace gini_wid= 	0.5609266	if country ==	32	& survey ==	2007
replace gini_wid= 	0.538291885	if country ==	32	& survey ==	2008
replace gini_wid= 	0.533392692	if country ==	32	& survey ==	2009
replace gini_wid= 	0.533317416	if country ==	32	& survey ==	2010
replace gini_wid= 	0.527508894	if country ==	32	& survey ==	2011
replace gini_wid= 	0.507782572	if country ==	32	& survey ==	2013
replace gini_wid= 	0.539022428	if country ==	32	& survey ==	2018
replace gini_wid= 	0.565986962	if country ==	32	& survey ==	2020
					
replace gini_wid= 	0.653954969	if country ==	68	& survey ==	2006
replace gini_wid= 	0.664189615	if country ==	68	& survey ==	2007
replace gini_wid= 	0.657243031	if country ==	68	& survey ==	2008
replace gini_wid= 	0.645885234	if country ==	68	& survey ==	2009
replace gini_wid= 	0.64496496	if country ==	68	& survey ==	2010
replace gini_wid= 	0.638594913	if country ==	68	& survey ==	2011
replace gini_wid= 	0.634891941	if country ==	68	& survey ==	2013
replace gini_wid= 	0.626630183	if country ==	68	& survey ==	2018
replace gini_wid= 	0.624586062	if country ==	68	& survey ==	2020
					
replace gini_wid= 	0.687105297	if country ==	76	& survey ==	2006
replace gini_wid= 	0.667846211	if country ==	76	& survey ==	2007
replace gini_wid= 	0.677146146	if country ==	76	& survey ==	2008
replace gini_wid= 	0.688009266	if country ==	76	& survey ==	2009
replace gini_wid= 	0.688330544	if country ==	76	& survey ==	2010
replace gini_wid= 	0.688651704	if country ==	76	& survey ==	2011
replace gini_wid= 	0.672959509	if country ==	76	& survey ==	2013
replace gini_wid= 	0.678834932	if country ==	76	& survey ==	2018
replace gini_wid= 	0.686446862	if country ==	76	& survey ==	2020
					
replace gini_wid= 	0.716799011	if country ==	152	& survey ==	2006
replace gini_wid= 	0.716136524	if country ==	152	& survey ==	2007
replace gini_wid= 	0.715474017	if country ==	152	& survey ==	2008
replace gini_wid= 	0.714843737	if country ==	152	& survey ==	2009
replace gini_wid= 	0.725463487	if country ==	152	& survey ==	2010
replace gini_wid= 	0.736115417	if country ==	152	& survey ==	2011
replace gini_wid= 	0.718891486	if country ==	152	& survey ==	2013
replace gini_wid= 	0.705524927	if country ==	152	& survey ==	2018
replace gini_wid= 	0.705525014	if country ==	152	& survey ==	2020
					
replace gini_wid= 	0.673866208	if country ==	170	& survey ==	2006
replace gini_wid= 	0.679182017	if country ==	170	& survey ==	2007
replace gini_wid= 	0.684497817	if country ==	170	& survey ==	2008
replace gini_wid= 	0.680025024	if country ==	170	& survey ==	2009
replace gini_wid= 	0.677323835	if country ==	170	& survey ==	2010
replace gini_wid= 	0.671418265	if country ==	170	& survey ==	2011
replace gini_wid= 	0.661058083	if country ==	170	& survey ==	2013
replace gini_wid= 	0.66130925	if country ==	170	& survey ==	2018
replace gini_wid= 	0.661309233	if country ==	170	& survey ==	2020
					
replace gini_wid= 	0.633407588	if country ==	188	& survey ==	2006
replace gini_wid= 	0.633407663	if country ==	188	& survey ==	2007
replace gini_wid= 	0.633407573	if country ==	188	& survey ==	2008
replace gini_wid= 	0.633407649	if country ==	188	& survey ==	2009
replace gini_wid= 	0.633407612	if country ==	188	& survey ==	2010
replace gini_wid= 	0.643161032	if country ==	188	& survey ==	2011
replace gini_wid= 	0.649709665	if country ==	188	& survey ==	2013
replace gini_wid= 	0.656714892	if country ==	188	& survey ==	2018
replace gini_wid= 	0.647605125 if country ==	188	& survey ==	2020
					
replace gini_wid= 	0.653954933	if country ==	214	& survey ==	2006
replace gini_wid= 	0.664189594	if country ==	214	& survey ==	2007
replace gini_wid= 	0.657243109	if country ==	214	& survey ==	2008
replace gini_wid= 	0.645885234	if country ==	214	& survey ==	2009
replace gini_wid= 	0.644965029	if country ==	214	& survey ==	2010
replace gini_wid= 	0.638594865	if country ==	214	& survey ==	2011
replace gini_wid= 	0.634891974	if country ==	214	& survey ==	2012
replace gini_wid= 	0.626630183	if country ==	214	& survey ==	2018
replace gini_wid= 	0.624586187	if country ==	214	& survey ==	2020
					
replace gini_wid= 	0.630172642	if country ==	218	& survey ==	2006
replace gini_wid= 	0.649650775	if country ==	218	& survey ==	2007
replace gini_wid= 	0.614627169	if country ==	218	& survey ==	2008
replace gini_wid= 	0.589535163	if country ==	218	& survey ==	2009
replace gini_wid= 	0.619485225	if country ==	218	& survey ==	2010
replace gini_wid= 	0.567844433	if country ==	218	& survey ==	2011
replace gini_wid= 	0.579070935	if country ==	218	& survey ==	2013
replace gini_wid= 	0.539847448	if country ==	218	& survey ==	2018
replace gini_wid= 	0.544607349	if country ==	218	& survey ==	2020
					
replace gini_wid= 	0.638741189	if country ==	222	& survey ==	2006
replace gini_wid= 	0.656537124	if country ==	222	& survey ==	2007
replace gini_wid= 	0.649580766	if country ==	222	& survey ==	2008
replace gini_wid= 	0.642627289	if country ==	222	& survey ==	2009
replace gini_wid= 	0.61540894	if country ==	222	& survey ==	2010
replace gini_wid= 	0.6191798	if country ==	222	& survey ==	2011
replace gini_wid= 	0.65382443	if country ==	222	& survey ==	2013
replace gini_wid= 	0.588284515	if country ==	222	& survey ==	2018
replace gini_wid= 	0.587337905	if country ==	222	& survey ==	2020
					
replace gini_wid= 	0.653954901	if country ==	320	& survey ==	2006
replace gini_wid= 	0.664189628	if country ==	320	& survey ==	2007
replace gini_wid= 	0.657243105	if country ==	320	& survey ==	2008
replace gini_wid= 	0.64588517	if country ==	320	& survey ==	2009
replace gini_wid= 	0.644964939	if country ==	320	& survey ==	2010
replace gini_wid= 	0.638594913	if country ==	320	& survey ==	2011
replace gini_wid= 	0.634892004	if country ==	320	& survey ==	2013
replace gini_wid= 	0.626630235	if country ==	320	& survey ==	2018
replace gini_wid= 	0.624586159	if country ==	320	& survey ==	2020
					
replace gini_wid= 	0.653954909	if country ==	340	& survey ==	2006
replace gini_wid= 	0.664189616	if country ==	340	& survey ==	2007
replace gini_wid= 	0.657243025	if country ==	340	& survey ==	2008
replace gini_wid= 	0.645885246	if country ==	340	& survey ==	2009
replace gini_wid= 	0.644964952	if country ==	340	& survey ==	2010
replace gini_wid= 	0.638594841	if country ==	340	& survey ==	2011
replace gini_wid= 	0.634891888	if country ==	340	& survey ==	2013
replace gini_wid= 	0.626630258	if country ==	340	& survey ==	2018
replace gini_wid= 	0.624586169	if country ==	340	& survey ==	2020
					
replace gini_wid= 	0.699983949	if country ==	484	& survey ==	2006
replace gini_wid= 	0.71001391	if country ==	484	& survey ==	2007
replace gini_wid= 	0.720043849	if country ==	484	& survey ==	2008
replace gini_wid= 	0.717103811	if country ==	484	& survey ==	2009
replace gini_wid= 	0.714163831	if country ==	484	& survey ==	2010
replace gini_wid= 	0.722062452	if country ==	484	& survey ==	2011
replace gini_wid= 	0.728800301	if country ==	484	& survey ==	2013
replace gini_wid= 	0.708394914	if country ==	484	& survey ==	2018
replace gini_wid= 	0.708394874	if country ==	484	& survey ==	2020
					
replace gini_wid= 	0.653954885	if country ==	558	& survey ==	2006
replace gini_wid= 	0.664189666	if country ==	558	& survey ==	2007
replace gini_wid= 	0.657243103	if country ==	558	& survey ==	2008
replace gini_wid= 	0.645885168	if country ==	558	& survey ==	2009
replace gini_wid= 	0.644964939	if country ==	558	& survey ==	2010
replace gini_wid= 	0.638594915	if country ==	558	& survey ==	2011
replace gini_wid= 	0.634891965	if country ==	558	& survey ==	2013
replace gini_wid= 	0.626630218	if country ==	558	& survey ==	2018
replace gini_wid= 	0.624586077	if country ==	558	& survey ==	2020
					
replace gini_wid= 	0.653954906	if country ==	591	& survey ==	2006
replace gini_wid= 	0.664189606	if country ==	591	& survey ==	2007
replace gini_wid= 	0.657243083	if country ==	591	& survey ==	2008
replace gini_wid= 	0.645885188	if country ==	591	& survey ==	2009
replace gini_wid= 	0.644965033	if country ==	591	& survey ==	2010
replace gini_wid= 	0.638594915	if country ==	591	& survey ==	2011
replace gini_wid= 	0.634892032	if country ==	591	& survey ==	2013
replace gini_wid= 	0.626630219	if country ==	591	& survey ==	2018
replace gini_wid= 	0.624586162	if country ==	591	& survey ==	2020
					
replace gini_wid= 	0.653954909	if country ==	600	& survey ==	2006
replace gini_wid= 	0.664189666	if country ==	600	& survey ==	2007
replace gini_wid= 	0.657243096	if country ==	600	& survey ==	2008
replace gini_wid= 	0.645885303	if country ==	600	& survey ==	2009
replace gini_wid= 	0.644964929	if country ==	600	& survey ==	2010
replace gini_wid= 	0.63859485	if country ==	600	& survey ==	2011
replace gini_wid= 	0.634891959	if country ==	600	& survey ==	2013
replace gini_wid= 	0.626630161	if country ==	600	& survey ==	2018
replace gini_wid= 	0.62458618	if country ==	600	& survey ==	2020
					
replace gini_wid= 	0.701798619	if country ==	604	& survey ==	2006
replace gini_wid= 	0.712653794	if country ==	604	& survey ==	2007
replace gini_wid= 	0.697204366	if country ==	604	& survey ==	2008
replace gini_wid= 	0.684497992	if country ==	604	& survey ==	2009
replace gini_wid= 	0.682680388	if country ==	604	& survey ==	2010
replace gini_wid= 	0.682814704	if country ==	604	& survey ==	2011
replace gini_wid= 	0.676565663	if country ==	604	& survey ==	2013
replace gini_wid= 	0.700177985	if country ==	604	& survey ==	2018
replace gini_wid= 	0.65150016	if country ==	604	& survey ==	2020
					
replace gini_wid= 	0.604056601	if country ==	858	& survey ==	2006
replace gini_wid= 	0.624765763	if country ==	858	& survey ==	2007
replace gini_wid= 	0.618321678	if country ==	858	& survey ==	2008
replace gini_wid= 	0.562967188	if country ==	858	& survey ==	2009
replace gini_wid= 	0.548512709	if country ==	858	& survey ==	2010
replace gini_wid= 	0.531759327	if country ==	858	& survey ==	2011
replace gini_wid= 	0.51513911	if country ==	858	& survey ==	2013
replace gini_wid= 	0.518278813	if country ==	858	& survey ==	2018
replace gini_wid= 	0.510166581	if country ==	858	& survey ==	2020

replace gini_wid= 	0.653954935	if country ==	862	& survey ==	2006
replace gini_wid= 	0.664189692	if country ==	862	& survey ==	2007
replace gini_wid= 	0.657243112	if country ==	862	& survey ==	2008
replace gini_wid= 	0.645885234	if country ==	862	& survey ==	2009
replace gini_wid= 	0.644965086	if country ==	862	& survey ==	2010
replace gini_wid= 	0.638594815	if country ==	862	& survey ==	2011
replace gini_wid= 	0.634891964	if country ==	862	& survey ==	2013
replace gini_wid= 	0.626630258	if country ==	862	& survey ==	2018
replace gini_wid= 	0.624586164	if country ==	862	& survey ==	2020



gen p10p50 = .
lab var p10p50 "Ratio p10/p50"

replace p10p50= 	12.88382339	if country ==	32	& survey ==	2006
replace p10p50= 	14.79523563	if country ==	32	& survey ==	2007
replace p10p50= 	13.18722057	if country ==	32	& survey ==	2008
replace p10p50= 	12.88259029	if country ==	32	& survey ==	2009
replace p10p50= 	12.87326813	if country ==	32	& survey ==	2010
replace p10p50= 	12.47995472	if country ==	32	& survey ==	2011
replace p10p50= 	11.19484425	if country ==	32	& survey ==	2013
replace p10p50= 	13.15313435	if country ==	32	& survey ==	2018
replace p10p50= 	15.08658886	if country ==	32	& survey ==	2020
					
replace p10p50= 	25.91447449	if country ==	68	& survey ==	2006
replace p10p50= 	27.28881264	if country ==	68	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	68	& survey ==	2008
replace p10p50= 	24.70032501	if country ==	68	& survey ==	2009
replace p10p50= 	24.4631424	if country ==	68	& survey ==	2010
replace p10p50= 	23.49921989	if country ==	68	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	68	& survey ==	2013
replace p10p50= 	21.72959709	if country ==	68	& survey ==	2018
replace p10p50= 	21.48442078	if country ==	68	& survey ==	2020
					
replace p10p50= 	30.32037354	if country ==	76	& survey ==	2006
replace p10p50= 	26.85725403	if country ==	76	& survey ==	2007
replace p10p50= 	28.28574181	if country ==	76	& survey ==	2008
replace p10p50= 	29.80868149	if country ==	76	& survey ==	2009
replace p10p50= 	29.92463493	if country ==	76	& survey ==	2010
replace p10p50= 	30.04084396	if country ==	76	& survey ==	2011
replace p10p50= 	27.43422508	if country ==	76	& survey ==	2013
replace p10p50= 	29.52854919	if country ==	76	& survey ==	2018
replace p10p50= 	30.61859322	if country ==	76	& survey ==	2020
					
replace p10p50= 	37.21633148	if country ==	152	& survey ==	2006
replace p10p50= 	37.45347977	if country ==	152	& survey ==	2007
replace p10p50= 	37.69587708	if country ==	152	& survey ==	2008
replace p10p50= 	37.94366074	if country ==	152	& survey ==	2009
replace p10p50= 	40.40129852	if country ==	152	& survey ==	2010
replace p10p50= 	43.03154373	if country ==	152	& survey ==	2011
replace p10p50= 	38.01935577	if country ==	152	& survey ==	2013
replace p10p50= 	34.14433289	if country ==	152	& survey ==	2018
replace p10p50= 	34.14435577	if country ==	152	& survey ==	2020
					
replace p10p50= 	30.3777504	if country ==	170	& survey ==	2006
replace p10p50= 	31.68453217	if country ==	170	& survey ==	2007
replace p10p50= 	33.0869751	if country ==	170	& survey ==	2008
replace p10p50= 	32.21496582	if country ==	170	& survey ==	2009
replace p10p50= 	31.45561028	if country ==	170	& survey ==	2010
replace p10p50= 	29.59788322	if country ==	170	& survey ==	2011
replace p10p50= 	27.81982994	if country ==	170	& survey ==	2013
replace p10p50= 	27.52890778	if country ==	170	& survey ==	2018
replace p10p50= 	27.52892303	if country ==	170	& survey ==	2020
					
replace p10p50= 	23.3376255	if country ==	188	& survey ==	2006
replace p10p50= 	23.3376255	if country ==	188	& survey ==	2007
replace p10p50= 	23.3376255	if country ==	188	& survey ==	2008
replace p10p50= 	23.3376255	if country ==	188	& survey ==	2009
replace p10p50= 	23.33761406	if country ==	188	& survey ==	2010
replace p10p50= 	24.85592842	if country ==	188	& survey ==	2011
replace p10p50= 	26.55161667	if country ==	188	& survey ==	2013
replace p10p50= 	27.14089394	if country ==	188	& survey ==	2018
replace p10p50= 	25.8552494	if country ==	188	& survey ==	2020
					
replace p10p50= 	25.91447449	if country ==	214	& survey ==	2006
replace p10p50= 	27.28881264	if country ==	214	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	214	& survey ==	2008
replace p10p50= 	24.70032501	if country ==	214	& survey ==	2009
replace p10p50= 	24.46315575	if country ==	214	& survey ==	2010
replace p10p50= 	23.49920464	if country ==	214	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	214	& survey ==	2012
replace p10p50= 	21.72959709	if country ==	214	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	214	& survey ==	2020
					
replace p10p50= 	22.21455383	if country ==	218	& survey ==	2006
replace p10p50= 	24.8687706	if country ==	218	& survey ==	2007
replace p10p50= 	20.40381241	if country ==	218	& survey ==	2008
replace p10p50= 	17.86679268	if country ==	218	& survey ==	2009
replace p10p50= 	20.83856201	if country ==	218	& survey ==	2010
replace p10p50= 	15.68975544	if country ==	218	& survey ==	2011
replace p10p50= 	16.64621735	if country ==	218	& survey ==	2013
replace p10p50= 	13.42599964	if country ==	218	& survey ==	2018
replace p10p50= 	13.82509995	if country ==	218	& survey ==	2020
					
replace p10p50= 	25.60433388	if country ==	222	& survey ==	2006
replace p10p50= 	28.02418137	if country ==	222	& survey ==	2007
replace p10p50= 	27.01335144	if country ==	222	& survey ==	2008
replace p10p50= 	26.03994942	if country ==	222	& survey ==	2009
replace p10p50= 	22.28545952	if country ==	222	& survey ==	2010
replace p10p50= 	22.49148941	if country ==	222	& survey ==	2011
replace p10p50= 	26.85247231	if country ==	222	& survey ==	2013
replace p10p50= 	18.72462082	if country ==	222	& survey ==	2018
replace p10p50= 	18.46478844	if country ==	222	& survey ==	2020
					
replace p10p50= 	25.91445732	if country ==	320	& survey ==	2006
replace p10p50= 	27.28881645	if country ==	320	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	320	& survey ==	2008
replace p10p50= 	24.7003212	if country ==	320	& survey ==	2009
replace p10p50= 	24.4631424	if country ==	320	& survey ==	2010
replace p10p50= 	23.49921989	if country ==	320	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	320	& survey ==	2013
replace p10p50= 	21.72960854	if country ==	320	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	320	& survey ==	2020
					
replace p10p50= 	25.91447258	if country ==	340	& survey ==	2006
replace p10p50= 	27.28881264	if country ==	340	& survey ==	2007
replace p10p50= 	26.2815094	if country ==	340	& survey ==	2008
replace p10p50= 	24.70032501	if country ==	340	& survey ==	2009
replace p10p50= 	24.4631424	if country ==	340	& survey ==	2010
replace p10p50= 	23.49921608	if country ==	340	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	340	& survey ==	2013
replace p10p50= 	21.72960854	if country ==	340	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	340	& survey ==	2020
					
replace p10p50= 	36.16650009	if country ==	484	& survey ==	2006
replace p10p50= 	38.17707062	if country ==	484	& survey ==	2007
replace p10p50= 	40.32211685	if country ==	484	& survey ==	2008
replace p10p50= 	40.03962708	if country ==	484	& survey ==	2009
replace p10p50= 	39.75511169	if country ==	484	& survey ==	2010
replace p10p50= 	41.49079514	if country ==	484	& survey ==	2011
replace p10p50= 	42.80047989	if country ==	484	& survey ==	2013
replace p10p50= 	36.33327484	if country ==	484	& survey ==	2018
replace p10p50= 	36.33327484	if country ==	484	& survey ==	2020
					
replace p10p50= 	25.91447258	if country ==	558	& survey ==	2006
replace p10p50= 	27.28881645	if country ==	558	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	558	& survey ==	2008
replace p10p50= 	24.7003212	if country ==	558	& survey ==	2009
replace p10p50= 	24.4631424	if country ==	558	& survey ==	2010
replace p10p50= 	23.49921989	if country ==	558	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	558	& survey ==	2013
replace p10p50= 	21.72959709	if country ==	558	& survey ==	2018
replace p10p50= 	21.48441124	if country ==	558	& survey ==	2020
					
replace p10p50= 	25.91445732	if country ==	591	& survey ==	2006
replace p10p50= 	27.28881264	if country ==	591	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	591	& survey ==	2008
replace p10p50= 	24.7003212	if country ==	591	& survey ==	2009
replace p10p50= 	24.46315575	if country ==	591	& survey ==	2010
replace p10p50= 	23.49921989	if country ==	591	& survey ==	2011
replace p10p50= 	22.77589226	if country ==	591	& survey ==	2013
replace p10p50= 	21.72959709	if country ==	591	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	591	& survey ==	2020
					
replace p10p50= 	25.91447258	if country ==	600	& survey ==	2006
replace p10p50= 	27.28881645	if country ==	600	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	600	& survey ==	2008
replace p10p50= 	24.70033836	if country ==	600	& survey ==	2009
replace p10p50= 	24.46315384	if country ==	600	& survey ==	2010
replace p10p50= 	23.49921608	if country ==	600	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	600	& survey ==	2013
replace p10p50= 	21.72959709	if country ==	600	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	600	& survey ==	2020
					
replace p10p50= 	37.78202438	if country ==	604	& survey ==	2006
replace p10p50= 	39.02636719	if country ==	604	& survey ==	2007
replace p10p50= 	36.09077835	if country ==	604	& survey ==	2008
replace p10p50= 	32.99256897	if country ==	604	& survey ==	2009
replace p10p50= 	31.68337631	if country ==	604	& survey ==	2010
replace p10p50= 	32.12794876	if country ==	604	& survey ==	2011
replace p10p50= 	30.69269562	if country ==	604	& survey ==	2013
replace p10p50= 	35.21310806	if country ==	604	& survey ==	2018
replace p10p50= 	25.9059906	if country ==	604	& survey ==	2020
					
replace p10p50= 	18.66558838	if country ==	858	& survey ==	2006
replace p10p50= 	20.68147087	if country ==	858	& survey ==	2007
replace p10p50= 	19.93585396	if country ==	858	& survey ==	2008
replace p10p50= 	15.04727554	if country ==	858	& survey ==	2009
replace p10p50= 	13.9533577	if country ==	858	& survey ==	2010
replace p10p50= 	12.7575922	if country ==	858	& survey ==	2011
replace p10p50= 	11.72604179	if country ==	858	& survey ==	2013
replace p10p50= 	11.83999538	if country ==	858	& survey ==	2018
replace p10p50= 	11.36078644	if country ==	858	& survey ==	2020

replace p10p50= 	25.91447449	if country ==	862	& survey ==	2006
replace p10p50= 	27.28883171	if country ==	862	& survey ==	2007
replace p10p50= 	26.28149414	if country ==	862	& survey ==	2008
replace p10p50= 	24.70032501	if country ==	862	& survey ==	2009
replace p10p50= 	24.46315575	if country ==	862	& survey ==	2010
replace p10p50= 	23.49921608	if country ==	862	& survey ==	2011
replace p10p50= 	22.77588081	if country ==	862	& survey ==	2013
replace p10p50= 	21.72960854	if country ==	862	& survey ==	2018
replace p10p50= 	21.48442268	if country ==	862	& survey ==	2020

gen p10 =.
lab var p10 "Top 10% BM"

replace p10= 	33.7	if country ==	32	& survey ==	2006
replace p10= 	33.7	if country ==	32	& survey ==	2007
replace p10= 	32.4	if country ==	32	& survey ==	2008
replace p10= 	31.2	if country ==	32	& survey ==	2009
replace p10= 	31.7	if country ==	32	& survey ==	2010
replace p10= 	31	if country ==	32	& survey ==	2011
replace p10= 	29.4	if country ==	32	& survey ==	2013
replace p10= 	29.8	if country ==	32	& survey ==	2018
replace p10= 	30.3	if country ==	32	& survey ==	2020
					
replace p10= 	43.6	if country ==	68	& survey ==	2006
replace p10= 	41.9	if country ==	68	& survey ==	2007
replace p10= 	38.5	if country ==	68	& survey ==	2008
replace p10= 	36.9	if country ==	68	& survey ==	2009
replace p10= 	36.9	if country ==	68	& survey ==	2010
replace p10= 	33.7	if country ==	68	& survey ==	2011
replace p10= 	35.2	if country ==	68	& survey ==	2013
replace p10= 	30.6	if country ==	68	& survey ==	2018
replace p10= 	32.6	if country ==	68	& survey ==	2020
					
replace p10= 	44.1	if country ==	76	& survey ==	2006
replace p10= 	43.2	if country ==	76	& survey ==	2007
replace p10= 	42.5	if country ==	76	& survey ==	2008
replace p10= 	42.2	if country ==	76	& survey ==	2009
replace p10= 	42.2	if country ==	76	& survey ==	2010
replace p10= 	41.7	if country ==	76	& survey ==	2011
replace p10= 	41.7	if country ==	76	& survey ==	2013
replace p10= 	42.5	if country ==	76	& survey ==	2018
replace p10= 	39.4	if country ==	76	& survey ==	2020
					
replace p10= 	37.9	if country ==	152	& survey ==	2006
replace p10= 	37.9	if country ==	152	& survey ==	2007
replace p10= 	37.9	if country ==	152	& survey ==	2008
replace p10= 	38.2	if country ==	152	& survey ==	2009
replace p10= 	38.2	if country ==	152	& survey ==	2010
replace p10= 	37.3	if country ==	152	& survey ==	2011
replace p10= 	37.4	if country ==	152	& survey ==	2013
replace p10= 	36.3	if country ==	152	& survey ==	2018
replace p10= 	35.8	if country ==	152	& survey ==	2020
					
replace p10= 	43.2	if country ==	170	& survey ==	2006
replace p10= 	43.2	if country ==	170	& survey ==	2007
replace p10= 	43.7	if country ==	170	& survey ==	2008
replace p10= 	42.9	if country ==	170	& survey ==	2009
replace p10= 	43.4	if country ==	170	& survey ==	2010
replace p10= 	42.4	if country ==	170	& survey ==	2011
replace p10= 	41.4	if country ==	170	& survey ==	2013
replace p10= 	39.7	if country ==	170	& survey ==	2018
replace p10= 	42.2	if country ==	170	& survey ==	2020
					
replace p10= 	38.3	if country ==	188	& survey ==	2006
replace p10= 	38.9	if country ==	188	& survey ==	2007
replace p10= 	37.7	if country ==	188	& survey ==	2008
replace p10= 	39.4	if country ==	188	& survey ==	2009
replace p10= 	36.8	if country ==	188	& survey ==	2010
replace p10= 	36.9	if country ==	188	& survey ==	2011
replace p10= 	37	if country ==	188	& survey ==	2013
replace p10= 	36.3	if country ==	188	& survey ==	2018
replace p10= 	37	if country ==	188	& survey ==	2020
					
replace p10= 	41.2	if country ==	214	& survey ==	2006
replace p10= 	38.6	if country ==	214	& survey ==	2007
replace p10= 	37.8	if country ==	214	& survey ==	2008
replace p10= 	38.7	if country ==	214	& survey ==	2009
replace p10= 	36.5	if country ==	214	& survey ==	2010
replace p10= 	37.5	if country ==	214	& survey ==	2011
replace p10= 	37.9	if country ==	214	& survey ==	2012
replace p10= 	35.2	if country ==	214	& survey ==	2018
replace p10= 	30.5	if country ==	214	& survey ==	2020
					
replace p10= 	41.1	if country ==	218	& survey ==	2006
replace p10= 	42	if country ==	218	& survey ==	2007
replace p10= 	38.1	if country ==	218	& survey ==	2008
replace p10= 	37.1	if country ==	218	& survey ==	2009
replace p10= 	37.5	if country ==	218	& survey ==	2010
replace p10= 	34.1	if country ==	218	& survey ==	2011
replace p10= 	35.7	if country ==	218	& survey ==	2013
replace p10= 	34.4	if country ==	218	& survey ==	2018
replace p10= 	36	if country ==	218	& survey ==	2020
					
replace p10= 	35.6	if country ==	222	& survey ==	2006
replace p10= 	35.7	if country ==	222	& survey ==	2007
replace p10= 	36.1	if country ==	222	& survey ==	2008
replace p10= 	36	if country ==	222	& survey ==	2009
replace p10= 	33.2	if country ==	222	& survey ==	2010
replace p10= 	32.8	if country ==	222	& survey ==	2011
replace p10= 	34.2	if country ==	222	& survey ==	2013
replace p10= 	29.4	if country ==	222	& survey ==	2018
replace p10= 	29.8	if country ==	222	& survey ==	2020
					
replace p10= 	43.2	if country ==	320	& survey ==	2006
replace p10= 	43.2	if country ==	320	& survey ==	2007
replace p10= 	43.2	if country ==	320	& survey ==	2008
replace p10= 	43.2	if country ==	320	& survey ==	2009
replace p10= 	43.2	if country ==	320	& survey ==	2010
replace p10= 	43.2	if country ==	320	& survey ==	2011
replace p10= 	43.2	if country ==	320	& survey ==	2013
replace p10= 	38.1	if country ==	320	& survey ==	2018
replace p10= 	38.1	if country ==	320	& survey ==	2020
					
replace p10= 	44	if country ==	340	& survey ==	2006
replace p10= 	43.1	if country ==	340	& survey ==	2007
replace p10= 	43	if country ==	340	& survey ==	2008
replace p10= 	38.4	if country ==	340	& survey ==	2009
replace p10= 	40.2	if country ==	340	& survey ==	2010
replace p10= 	39.7	if country ==	340	& survey ==	2011
replace p10= 	37	if country ==	340	& survey ==	2013
replace p10= 	35.3	if country ==	340	& survey ==	2018
replace p10= 	34.6	if country ==	340	& survey ==	2020
					
replace p10= 	38.9	if country ==	484	& survey ==	2006
replace p10= 	38.9	if country ==	484	& survey ==	2007
replace p10= 	39.1	if country ==	484	& survey ==	2008
replace p10= 	39.1	if country ==	484	& survey ==	2009
replace p10= 	37.1	if country ==	484	& survey ==	2010
replace p10= 	37.1	if country ==	484	& survey ==	2011
replace p10= 	38.9	if country ==	484	& survey ==	2013
replace p10= 	37.1	if country ==	484	& survey ==	2018
replace p10= 	35.5	if country ==	484	& survey ==	2020
					
replace p10= 	39.6	if country ==	558	& survey ==	2006
replace p10= 	39.6	if country ==	558	& survey ==	2007
replace p10= 	39.6	if country ==	558	& survey ==	2008
replace p10= 	34.2	if country ==	558	& survey ==	2009
replace p10= 	34.2	if country ==	558	& survey ==	2010
replace p10= 	34.2	if country ==	558	& survey ==	2011
replace p10= 	34.2	if country ==	558	& survey ==	2013
replace p10= 	37.2	if country ==	558	& survey ==	2018
replace p10= 	37.2	if country ==	558	& survey ==	2020
					
replace p10= 	41.1	if country ==	591	& survey ==	2006
replace p10= 	39.7	if country ==	591	& survey ==	2007
replace p10= 	40.7	if country ==	591	& survey ==	2008
replace p10= 	40.1	if country ==	591	& survey ==	2009
replace p10= 	39.7	if country ==	591	& survey ==	2010
replace p10= 	39.7	if country ==	591	& survey ==	2011
replace p10= 	39.6	if country ==	591	& survey ==	2013
replace p10= 	37.1	if country ==	591	& survey ==	2018
replace p10= 	38	if country ==	591	& survey ==	2020
					
replace p10= 	42.4	if country ==	600	& survey ==	2006
replace p10= 	42.5	if country ==	600	& survey ==	2007
replace p10= 	40.1	if country ==	600	& survey ==	2008
replace p10= 	38.1	if country ==	600	& survey ==	2009
replace p10= 	40.5	if country ==	600	& survey ==	2010
replace p10= 	41.4	if country ==	600	& survey ==	2011
replace p10= 	37.3	if country ==	600	& survey ==	2013
replace p10= 	35.8	if country ==	600	& survey ==	2018
replace p10= 	33.3	if country ==	600	& survey ==	2020
					
replace p10= 	38.2	if country ==	604	& survey ==	2006
replace p10= 	37.8	if country ==	604	& survey ==	2007
replace p10= 	35.4	if country ==	604	& survey ==	2008
replace p10= 	35.2	if country ==	604	& survey ==	2009
replace p10= 	34.2	if country ==	604	& survey ==	2010
replace p10= 	33.5	if country ==	604	& survey ==	2011
replace p10= 	32.7	if country ==	604	& survey ==	2013
replace p10= 	31.6	if country ==	604	& survey ==	2018
replace p10= 	32.9	if country ==	604	& survey ==	2020
					
replace p10= 	35	if country ==	858	& survey ==	2006
replace p10= 	35.4	if country ==	858	& survey ==	2007
replace p10= 	34.3	if country ==	858	& survey ==	2008
replace p10= 	34.6	if country ==	858	& survey ==	2009
replace p10= 	33.6	if country ==	858	& survey ==	2010
replace p10= 	31.6	if country ==	858	& survey ==	2011
replace p10= 	30.1	if country ==	858	& survey ==	2013
replace p10= 	29.7	if country ==	858	& survey ==	2018
replace p10= 	29.9	if country ==	858	& survey ==	2020



*Percepción situación económica
recode sit_econ_gral 1/3=0 4/5=1, gen(sit)

bys countryyear: egen situ_econ = mean(sit)
replace situ_econ = situ_econ * 100
lab var situ_econ "Percepción de mala o muy mala situación económica en el país"
drop sit


*******************Indice estatus objetiv0************************

********Versión MCA***********
mca comp lavadora telef celular coche vivienda ocup educh
mcaplot, overlay legend(on) xline(0) yline(0) scale(.5) 
predict status_mca

replace status_mca = status_mca*-1 //rota los valores

sum status_mca
gen status_obj = ((status_mca + 2.451487) / (3.897332 + 2.451487))*10 // rescalamiento (a1 - min) / (max - min)

lab var status_obj "Estatus objetivo"

xtile status_10 = status_obj [aw = wt], nq(10)


*******Variables seleccionadas para base final******************
keep numinves idenpa numentre subh sex age age2 cat_ocup ocup educ educh sit_econ_gral ideologia comp lavadora telef celular coche agua_pot agua_cal cloaca vivienda survey country anio pais countryyear gdp gini sit situ_econ status_mca status_obj log_gdp log_gdp_wid gini_wid p10p50 p10 wt 

cd "C:\Users\xxxxxx\" // Cambiar por direccion en donde se quiera colocar la base 
compress
save latinobarometro20062020.dta, replace